<?php 
use yii\helpers\Html;
use yii\widgets\ActiveForm;
 ?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
  <div class="body-content">
<?php $form = ActiveForm::begin(['action'=>['area/add'],'options'=>['class' => 'form-x']]);  ?>
      <div class="form-group" id="post_div">
        <div class="label">
          <label>选择分类：</label>
        </div>
            <select name="parent_id" class="" style="height:70px:width:200px; line-height:17px;">
              <?php foreach ($info as $key => $value): ?>
                <option value="<?=$value['area_id'] ?>"><?=$value['area_name'] ?></option>
              <?php endforeach ?>
            </select>
      </div>
      <div class="form-group">
        <div class="label">
          <label>职位名：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="right" data-validate="required:职位名不能为空" />
          <div class="tips"></div>
        </div>
      </div>     
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
<?php ActiveForm::end(); ?>  
  </div>
</div>

</body></html>
<script type="text/javascript" src="Jquery/jquery.js"></script>
<script type="text/javascript">
	$(document).on("change","select[name='parent_id']",function(){
		var p_id = $(this).val();
		$(this).nextAll().remove();
		$.ajax({
			url:"index.php?r=area/ajax",
			dataType:"json",
			type:"get",
			data:{
				id:p_id
			},
			success:function(data){
				if (data.error==1) {
					str = '<select name="parent_id" class="" style="height:70px:width:200px; line-height:17px;">';
					$.each(data.content,function(k,v){
					  str+="<option value='"+v.area_id+"'>"+v.area_name+"</option>";
					})
					  str+='</select>'; 
					  $("#post_div").find("select:last").after(str);
				}else{
					return false;
				}
			}
		})
	})
</script>